    <div class="container">
      <div class="bg-putih">

        <div class="jdl-page">
          <?php echo isset($judul)?$judul:'<font color="#ccc">Judul Belum Diberikan</font>'; ?>
          <div class="clearfix"></div>
        </div>
        
        <?php echo display_flash(); ?>

        <div class="row">
          <div class="col-xs-5">
            <div class="btn-group btn-group-sm" role="group">
              <a href="<?php echo site_url('obat_rusak/add'); ?>" class="btn btn-primary"><i class="fa fa-plus"></i>&nbsp;Tambah</a>
              <?php if($this->uri->segment(2) == "search"): ?>
                <?php 
                $filter = $this->session->userdata('filter'); 
                $keyword = $this->session->userdata('obat_rusak'); 
                $ses_before = $this->session->userdata('obat_rusak1'); 
                $ses_after = $this->session->userdata('obat_rusak2'); 
                ?>
                <?php 
                if($filter == "by_kelompok"){
                  $this->db->where('NmKelompok', $keyword);
                  $kelompok_id = $this->db->get('kelompok')->result_array();
                  $keyword = $kelompok_id[0]['KdKelompok'];
                }
                ?>

                <?php if($filter != "by_tanggal"): ?>
                  <a href="<?php echo site_url("obat_rusak/excel/$filter/$keyword"); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
                <?php else: ?>
                  <?php if($ses_before != "" && $ses_after != ""): ?>
                    <a href="<?php echo site_url("obat_rusak/excel/$filter/$ses_before/$ses_after"); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
                  <?php elseif($ses_before == ""): ?>
                    <a href="<?php echo site_url("obat_rusak/excel/$filter/null/$ses_after"); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
                  <?php elseif($ses_after == ""): ?>
                    <a href="<?php echo site_url("obat_rusak/excel/$filter/$ses_before/null"); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
                  <?php endif; ?>
                <?php endif; ?>
              <?php elseif($this->uri->segment(2) == ""): ?>
                <a href="<?php echo site_url('obat_rusak/excel'); ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i>&nbsp;Unduh Excel</a>
              <?php endif; ?>
            </div>
          </div>
          <!--
          <div class="col-xs-7">
            <?php echo form_open('obat_rusak/search'); ?>
            <div class="input-group-5">         
              <button type="submit" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-search"></span></button>
              <input type="text" class="form-control input-sm" name="nama" placeholder="Nama obat" value="<?=$this->session->userdata('nama');?>" placeholder="Nama obat"/>
              <script type="text/javascript">
                $(document).ready(function() {
                  $(".obat").select2();
                });
              </script>
              <select class="obat js-example-basic-single js-states form-control" name="kelompok">
                <?php  
                $klpk_getter = $this->db->get('kelompok');
                $res_klpk_getter = $klpk_getter->result_array();
                ?>
                <option value="" selected="selected">Kelompok</option>
                <?php foreach($res_klpk_getter as $kelompok):?>
                  <option value="<?php echo $kelompok['KdKelompok'] ?>"><?php echo $kelompok['NmKelompok'] ?></option>
                <?php endforeach; ?>
              </select>
              <script type="text/javascript">
                $(document).ready(function(){
                  $('#after, #before').datepicker({
                    dateFormat: "yy-mm-dd",
                    changeMonth: true,
                    changeYear: true
                  });
                });
              </script>
              <input id="after" type="text" name="after" class="form-control input-sm" placeholder="Tanggal Awal"/>     
              <input id="before" type="text" name="before" class="form-control input-sm" placeholder="Tanggal Akhir"/>
            </div>
            <?php echo form_close(); ?>
          </div>-->
          <div class="col-xs-6" style="float:right">
            <div class="input-group-3">
              <?php echo form_open('obat_rusak/search'); ?>
              <button id="btn-search" type="submit" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-search"></span></button>
              <select id="selector" class="form-control input-sm" name="filter" onchange='get_filter(this.value)'>
                <option value="by_name">Nama Obat</option>
                <option value="by_kelompok">Kelompok Obat</option>
                <option value="by_tanggal">Tanggal</option>                
              </select>                             
              <span id="frm-input">
                <input type="text" class="form-control input-sm" name="keyword" placeholder="Nama obat" value="<?=$this->session->userdata('nama');?>" placeholder="Nama obat"/>
              </span>
              <?php echo form_close(); ?>              
              <script type="text/javascript">
                function get_filter(filter){                  
                  var html_code;
                  if(filter == "by_tanggal"){
                    html_code = "<input id='after' type='text' name='keyword[]' class='form-control input-sm' placeholder='Tanggal Akhir' style='width:25%' value='<?php echo date('d/m/Y'); ?>'/>";
                    html_code += "<input id='before' type='text' name='keyword[]' class='form-control input-sm' placeholder='Tanggal Awal' style='width:25%' value='<?php echo date('1/m/Y'); ?>'/>";
                    $('#frm-input').html(html_code);
                    $(document).ready(function(){
                      $('#after, #before').datepicker({
                        dateFormat: "yy-mm-dd",
                        changeMonth: true,
                        changeYear: true
                      });
                    });
                  }else if(filter == "by_kelompok"){
                    html_code = "<select class='form-control obat' name='keyword'><?php foreach($obat as $value) { echo "<option value='$value[KdKelompok]'>$value[NmKelompok]</option>";}?></select>";
                    $('#frm-input').html(html_code);
                    $(".obat").select2();
                  }else if(filter == "by_name"){
                    html_code = '<input type="text" class="form-control input-sm" name="keyword" placeholder="Nama obat" value="<?=$this->session->userdata("nama");?>" placeholder="Nama obat"/>';
                    $('#frm-input').html(html_code);  
                  }
                }
              </script>
            </div>
          </div>
        </div>

        <table class="table table-striped table-hover margintop20">
          <thead>
            <tr>
              <th width="3%" style="text-align:center;">No</th>
              <th width="16%" style="text-align:left;">Kode Obat Rusak</th>
              <th width="20%" style="text-align:left;">Nama Obat</th>
              <th width="13%" style="text-align:left;">Tanggal</th>
              <th width="13%" style="text-align:left;">Jumlah</th>
              <th width="45%" style="text-align:left;">Keterangan</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            if(!empty($results)){
              foreach ($results as $row) {
                ?>
                <tr>
                  <td align="center"><?php echo $ordinal_num++ ?></td>
                  <td><?php echo $row['KdObatHilang']?></td>
                  <td><?php echo $row['NmObat']?></td>
                  <td>
                    <?php echo id_date($row['Tanggal'],'long')?>
                  </td>
                  <td><?php echo $row['Jumlah']?></td>
                  <td>
                    <?php echo trim_text($row['Keterangan'], 50)?>
                    <span class="pull-right">
                      <a href="<?php echo site_url('obat_rusak/edit/' . $row['KdObatHilang']) ?>" class="label label-success" title="Edit">Edit</a>
                      <a href="<?php echo site_url('obat_rusak/delete/' . $row['KdObatHilang']) ?>" class="label label-default" title="Hapus" onClick="return confirm('Yakin ingin menghapus <?php echo $row['KdObatHilang']?> ?')">Hapus</a>
                    </span>
                  </td>

                </tr>
                <?php 
              }
            }else{
              ?>
              <tr>
                <td colspan="6" align="center">Tidak ada data</td>
              </tr>
              <?php
            }
            ?>
          </tbody>
        </table>

        <center style="margin-top:-30px;">
          <ul class="pagination">
            <?php echo $pagination; ?>
          </ul>
        </center>

        <div class="clearfix"></div>
      </div>
    </div> <!-- /container -->